//
//  OfflineRemittanceViewModel.m
//  GLGW_Shoping
//
//  Created by yang on 2018/11/27.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "OfflineRemittanceViewModel.h"
#import "NoDataFootTableViewHeaderFooterView.h"
#import "ChangePayTableViewHeaderFooterView.h"
#import "OfflineRemittanceMoneyTableViewCell.h"
#import "OfflineRemittanceInofrTableViewCell.h"
#import "AdressSelectTableViewCell.h"
#import "OfflineRemittanceFootView.h"
#import "OrderOperationView.h"


@interface OfflineRemittanceViewModel ()<UITableViewDelegate,UITableViewDataSource>
{
    NSArray * leftArr;
}
@end

@implementation OfflineRemittanceViewModel

-(instancetype)initWithViewToViewModel:(UITableView *)tableView theSuperView:(UIView *)superView{
    if (self = [super initWithViewToViewModel:tableView theSuperView:superView]) {
        leftArr = @[@"户名",@"账户",@"开户行",@"联行号",@"汇款识别码",@"订单号"];
        tableView.mj_footer.hidden = YES;
        tableView.mj_header.hidden = YES;
        tableView.delegate = self;
        tableView.dataSource= self;
        tableView.tableFooterView = [self createFootView];
        [tableView registerClass:[ChangePayTableViewHeaderFooterView class] forHeaderFooterViewReuseIdentifier:@"ChangePayTableViewHeaderFooterView"];
        [tableView registerClass:[NoDataFootTableViewHeaderFooterView class] forHeaderFooterViewReuseIdentifier:@"NoDataFootTableViewHeaderFooterView"];
        [superView addSubview:tableView];
    }
    return self;
}

-(UIView *)createFootView{
    OfflineRemittanceFootView * footView = [[OfflineRemittanceFootView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, kHeightProportion_In_iPhoneTriploid(210))];
    footView.Block_payAtcion = ^{
        OrderOperationView * orderOpreAction = [[OrderOperationView alloc] initWithPopOrderOperation:@[@"确认"] theTitleStr:@"付款成功" theTosStr:@"您好，您的订单已完成线下付款\n等待商家确认收款！"];
        [orderOpreAction show];
        orderOpreAction.Block_CaseAction = ^(NSInteger tag) {
            DLog(@"确认");
        };
    };
    return footView;
}

#pragma mark --- UITableViewDelegate,UITableViewDataSource
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 1) {
        return leftArr.count;
    }else{
        return 1;
    }
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        return kHeightProportion_In_iPhoneTriploid(100);
    }else{
        return kHeightProportion_In_iPhoneTriploid(44);
    }
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    BaseTableViewCell * cell;
    switch (indexPath.section) {
        case 0:{
            OfflineRemittanceMoneyTableViewCell * cell_Money = [OfflineRemittanceMoneyTableViewCell cellWithTableView:tableView];
            cell = cell_Money;
        }
            break;
        case 1:{
            OfflineRemittanceInofrTableViewCell * cell_infro = [OfflineRemittanceInofrTableViewCell cellWithTableView:tableView];
            cell_infro.leftTieleStr = leftArr[indexPath.row];
            cell = cell_infro;
        }
            break;
        case 2:{
            AdressSelectTableViewCell * cell_push = [AdressSelectTableViewCell cellWithTableView:tableView];
            cell_push.leftTitString = @"上传银行回单";
            cell_push.inputTextField.hidden = YES;
            cell_push.showPush = YES;
            [cell_push setSepartionLineWith:lineModel_Half];
            cell = cell_push;
        }
            break;
            
        default:
            break;
    }
    
    return cell;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UITableViewHeaderFooterView * headerView;
    if (section == 1) {
        ChangePayTableViewHeaderFooterView * headerView_pay = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"ChangePayTableViewHeaderFooterView"];
        headerView_pay.leftTitleStr = @"线下汇款信息";
        headerView = headerView_pay;
    }else{
        NoDataFootTableViewHeaderFooterView * headerView_top = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"NoDataFootTableViewHeaderFooterView"];
        headerView = headerView_top;
    }
    return headerView;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section == 1) {
        return kHeightProportion_In_iPhoneTriploid(60);
    }else{
        return kHeightProportion_In_iPhoneTriploid(10);
    }
}

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    NoDataFootTableViewHeaderFooterView * footView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"NoDataFootTableViewHeaderFooterView"];
    return footView;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.001;
}



@end
